package com.vitogiovanni.tobook.servlet;


import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.vitogiovanni.tobook.entity.Gestore;
import com.vitogiovanni.tobook.entity.GestoreEndpoint;

/**
 * Servlet implementation class InvitaLavoroServlet
 */
public class InserisciServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public InserisciServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
				
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //UserService userService = UserServiceFactory.getUserService();
        //User user = userService.getCurrentUser();

        // We have one entity group per Guestbook with all Greetings residing
        // in the same entity group as the Guestbook to which they belong.
        // This lets us run a transactional ancestor query to retrieve all
        // Greetings for a given Guestbook.  However, the write rate to each
        // Guestbook should be limited to ~1/second.
        //String guestbookName = req.getParameter("guestbookName");
        //Key guestbookKey = KeyFactory.createKey(kind, id);
        //String content = req.getParameter("content");
        //Date date = new Date();
        Gestore greeting = new Gestore();
        greeting.setEmail("email");
        greeting.setPassword("password");
        greeting.setNome("nome");
        greeting.setCognome("cognome");
        
        GestoreEndpoint gestore = new GestoreEndpoint();
        gestore.insertGestore(greeting);
        
        //DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        //datastore.put(greeting);

        resp.sendRedirect("/index.html");
	}
	
	
}
